﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenExpressApp.MetaAttribute;
using OpenExpressApp.MetaModel;
using Csla;
using OpenExpressApp.Types;
using lite;

namespace OpenExpressApp.Module.Library
{
    [Serializable]
    [BusinessObject("1662B219-6554-4E42-8E36-D46793B8E068")]
    public partial class OrgPositionOperationCriteria : BusinessBase<OrgPositionOperationCriteria>, IQueryObject
    {
        //#region Properties

        [NotUndoable, NonSerialized]
        private BusinessObjectInfoList _businessObjectInfoList;

        [Association(CreateToolbar = false, IsRecur = false)]
        [Label("模块")]
        [QueryItemValueType(QueryItemValueType.Id, IdPropertyName = "ModuleId"), NavigateQueryItem]
        public BusinessObjectInfoList DefaultObjectInfoList
        {
            get
            {
                if (null == _businessObjectInfoList)
                    _businessObjectInfoList = BusinessObjectInfoList.GetModules();
                return _businessObjectInfoList;
            }
        }

        private Guid _moduleId;
        public Guid ModuleId
        {
            get
            {
                return this._moduleId;
            }
            set
            {
                this._moduleId = value;

                this.OnPropertyChanged("ModuleId");
            }
        }

        private BusinessObjectInfo _businessObjectInfo;
        /// <summary>
        /// 单选中的对象
        /// </summary>
        public BusinessObjectInfo BusinessObjectInfo
        {
            get
            {
                return this._businessObjectInfo;
            }
            set
            {
                this._businessObjectInfo = value;

                //同步SelectedBOs
                this.SelectedBOs.Clear();
                this._selectedBOs.Add(value);

                this.OnPropertyChanged("BusinessObjectInfo");
            }
        }

        private List<BusinessObjectInfo> _selectedBOs;
        /// <summary>
        /// 多选时，选中的所有对象
        /// </summary>
        public IList<BusinessObjectInfo> SelectedBOs
        {
            get
            {
                if (this._selectedBOs == null)
                {
                    this._selectedBOs = new List<BusinessObjectInfo>();
                }
                return this._selectedBOs;
            }
        }

        public void CheckRules() { }
    }
}
